package com.controller.qiantai;

import com.entity.*;
import com.entity.table.BGoodsTableDef;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryChain;
import com.mybatisflex.core.query.QueryWrapper;
import com.service.*;
import com.service.impl.BGoodsServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.*;

@Controller
public class IndexController {
    @Resource
    HomeService homeService;


    @GetMapping(value = "")
    public String index(Model model) {
        try {
            Home home = homeService.queryChain().one();
            model.addAttribute("home",home);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return "client/index";
    }
    @GetMapping(value = "/index")
    public String index1(Model model) {
        try {
            Home home = homeService.queryChain().one();
            model.addAttribute("home",home);
            return "client/index";
        }catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }

    @Resource
    BGoodsService bGoodsService;
    @GetMapping(value = "/page1")
    public String goods(Model model) {
        try {
            BGoods bGoods = bGoodsService.queryChain().one();
            model.addAttribute("bGoods",bGoods);
            return "client/page1";
        }catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }

    @Resource
    OriginService originService;
    @GetMapping(value = "/page2")
    public String origin(Model model){
        try {
            Origin origin = originService.queryChain().one();
            model.addAttribute("origin",origin);
            return "client/page2";
        }catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }
    @Resource
    AttachmentService attachmentService;
    @GetMapping(value = "/page3")
    public String attachment(Model model) {
        try {
            Attachment attachment = attachmentService.queryChain().one();
            model.addAttribute("attachment", attachment);
            return "client/page3";
        } catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }
    @Resource
    CustomService customService;
    @GetMapping(value = "/page4")
    public String custom(Model model) {
        try {
            Custom custom = customService.queryChain().one();
                model.addAttribute("custom", custom);
            return "client/page4";
        } catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }
    @Resource
    DevelopService developService;
    @GetMapping(value = "/page5")
    public String develop(Model model) {
        try {
            Develop develop = developService.queryChain().one();
            model.addAttribute("develop", develop);
            return "client/page5";
        } catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }
    @Resource
    NarrativeService narrativeService;
    @GetMapping(value = "/page6")
    public String Narrative(Model model) {
        try {
            Narrative narrative = narrativeService.queryChain().one();
            model.addAttribute("narrative", narrative);
            return "client/page6";
        } catch (Exception e) {
            e.printStackTrace();
            return "client/login";
        }
    }




}
